version: '3.8'

services:
    database:
        image: postgres:latest
        container_name: postgres
        volumes:
            - ./postgres-db-data:/var/lib/postgresql/data
        environment:
            - POSTGRES_USER=${DATABASE_USER}
            - POSTGRES_PASSWORD=${DATABASE_PASSWORD}
            - POSTGRES_DB=postgres
    db-migration-init:
        image: flyway/flyway
        command: -url=jdbc:postgresql://postgres:5432/postgres -user=${DATABASE_USER} -password=${DATABASE_PASSWORD} -connectRetries=60 migrate
        volumes:
        - ./migrations/init:/flyway/sql


    redmine:
        container_name: redmine
        image: docker.io/balaant/iu5-iu5-redmine-redmine-4
        volumes:
            - ./redmine-data:/usr/src/redmine/files
        environment:
            REDMINE_DB_POSTGRES: "postgres"
            REDMINE_DB_USERNAME: "${DATABASE_USER}"
            REDMINE_DB_PASSWORD: "${DATABASE_PASSWORD}"
            REDMINE_DB_DATABASE: "redmine"
            REDMINE_SECRET_KEY_BASE: "…"
        ports:
            - "3000:3000"
        depends_on:
            - database
    backend:
        build: ./backend
        command: bash -c "python manage.py makemigrations && python manage.py migrate && python manage.py runserver 0.0.0.0:8000"
        depends_on:
            - database
        ports:
            - "8000:8000"

    frontend:
        build: ./frontend
        volumes:
            - ./frontend/nginx.conf:/etc/nginx/conf.d/default.conf:ro
        ports:
            - '80:80'
        depends_on:
            - backend

